home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-09-28 | 5.2 KB | 178 lines | [TEXT/PJMM] |
- unit Threads;
-
- interface
-
- uses
- Types,Memory;
-
- type
- ThreadState = INTEGER;
-
- const
- kReadyThreadState = $0; { 0 }
- kStoppedThreadState = $1; { 1 }
- kRunningThreadState = $2; { 2 }
-
- { Error codes have been meoved to Errors.(pah) }
- { Thread environment characteristics }
-
- type
- ThreadTaskRef = Ptr;
-
- { Thread characteristics }
- ThreadStyle = LONGINT;
-
- const
- kCooperativeThread = $1; { 1L << 0 }
- kPreemptiveThread = $2; { 1L << 1 }
-
- { Thread identifiers }
-
- type
- ThreadID = LONGINT;
-
- const
- kNoThreadID = $0; { 0 }
- kCurrentThreadID = $1; { 1 }
- kApplicationThreadID = $2; { 2 }
-
- { Options when creating a thread }
-
- type
- ThreadOptions = LONGINT;
-
- const
- kNewSuspend = $1; { (1 << 0) }
- kUsePremadeThread = $2; { (1 << 1) }
- kCreateIfNeeded = $4; { (1 << 2) }
- kFPUNotNeeded = $8; { (1 << 3) }
- kExactMatchThread = $10; { (1 << 4) }
-
- { Information supplied to the custom scheduler }
-
- type
- SchedulerInfoRec = record
- InfoRecSize: LONGINT;
- CurrentThreadID: ThreadID;
- SuggestedThreadID: ThreadID;
- InterruptedCoopThreadID: ThreadID;
- end;
- SchedulerInfoRecPtr = ^SchedulerInfoRec;
-
- { The following ProcPtrs cannot be interchanged with UniversalProcPtrs because of differences between 680x0}
- {and PowerPC runtime architectures with regard to the implementation of the Thread Manager . }
-
- { Prototype for thread's entry (main) routine }
- ThreadEntryProcPtr = ProcPtr; { PROCEDURE (threadParam: UNIV Ptr); }
-
- { Prototype for custom thread scheduler routine }
- ThreadSchedulerProcPtr = ProcPtr; { FUNCTION (schedulerInfo: SchedulerInfoRecPtr): ThreadID; }
-
- { Prototype for custom thread switcher routine }
- ThreadSwitchProcPtr = ProcPtr; { PROCEDURE (threadBeingSwitched: ThreadID; switchProcParam: UNIV Ptr); }
-
- { Prototype for thread termination notification routine }
- ThreadTerminationProcPtr = ProcPtr; { PROCEDURE (threadTerminated: ThreadID; terminationProcParam: UNIV Ptr); }
-
- { Prototype for debugger NewThread notification }
- DebuggerNewThreadProcPtr = ProcPtr; { PROCEDURE (threadCreated: ThreadID); }
-
- { Prototype for debugger DisposeThread notification }
- DebuggerDisposeThreadProcPtr = ProcPtr; { PROCEDURE (threadDeleted: ThreadID); }
-
- { Prototype for debugger schedule notification }
- DebuggerThreadSchedulerProcPtr = ProcPtr; { FUNCTION (schedulerInfo: SchedulerInfoRecPtr): ThreadID; }
-
- { Thread Manager routines }
-
- function CreateThreadPool (threadStyl: ThreadStyle; numToCreate: INTEGER; stackSize: Size): OSErr;
- inline
- $303C, $0501, $ABF2;
-
- function GetFreeThreadCount (threadStyl: ThreadStyle; var freeCount: INTEGER): OSErr;
- inline
- $303C, $0402, $ABF2;
-
- function GetSpecificFreeThreadCount (threadStyl: ThreadStyle; stackSize: Size; var freeCount: INTEGER): OSErr;
- inline
- $303C, $0615, $ABF2;
-
- function GetDefaultThreadStackSize (threadStyl: ThreadStyle; var stackSize: Size): OSErr;
- inline
- $303C, $0413, $ABF2;
-
- function ThreadCurrentStackSpace (thread: ThreadID; var freeStack: LONGINT): OSErr;
- inline
- $303C, $0414, $ABF2;
-
- function NewThread (threadStyl: ThreadStyle; threadEntry: ThreadEntryProcPtr; threadParam: univ Ptr; stackSize: Size; options: ThreadOptions; threadResult: univ Ptr; var threadMade: ThreadID): OSErr;
- inline
- $303C, $0E03, $ABF2;
-
- function DisposeThread (threadToDump: ThreadID; threadResult: univ Ptr; recycleThread: BOOLEAN): OSErr;
- inline
- $303C, $0504, $ABF2;
-
- function YieldToThread (suggestedThread: ThreadID): OSErr;
- inline
- $303C, $0205, $ABF2;
-
- function YieldToAnyThread: OSErr;
- inline
- $42A7, $303C, $0205, $ABF2;
-
- function GetCurrentThread (var currentThreadID: ThreadID): OSErr;
- inline
- $303C, $0206, $ABF2;
-
- function GetThreadState (threadToGet: ThreadID; var threadStat: ThreadState): OSErr;
- inline
- $303C, $0407, $ABF2;
-
- function SetThreadState (threadToSet: ThreadID; newState: ThreadState; suggestedThread: ThreadID): OSErr;
- inline
- $303C, $0508, $ABF2;
-
- function SetThreadStateEndCritical (threadToSet: ThreadID; newState: ThreadState; suggestedThread: ThreadID): OSErr;
- inline
- $303C, $0512, $ABF2;
-
- function SetThreadScheduler (threadScheduler: ThreadSchedulerProcPtr): OSErr;
- inline
- $303C, $0209, $ABF2;
-
- function SetThreadSwitcher (thread: ThreadID; threadSwitcher: ThreadSwitchProcPtr; switchProcParam: univ Ptr; inOrOut: BOOLEAN): OSErr;
- inline
- $303C, $070A, $ABF2;
-
- function SetThreadTerminator (thread: ThreadID; threadTerminator: ThreadTerminationProcPtr; terminationProcParam: univ Ptr): OSErr;
- inline
- $303C, $0611, $ABF2;
-
- function ThreadBeginCritical: OSErr;
- inline
- $303C, $000B, $ABF2;
-
- function ThreadEndCritical: OSErr;
- inline
- $303C, $000C, $ABF2;
-
- function SetDebuggerNotificationProcs (notifyNewThread: DebuggerNewThreadProcPtr; notifyDisposeThread: DebuggerDisposeThreadProcPtr; notifyThreadScheduler: DebuggerThreadSchedulerProcPtr): OSErr;
- inline
- $303C, $060D, $ABF2;
-
- function GetThreadCurrentTaskRef (var threadTRef: ThreadTaskRef): OSErr;
- inline
- $303C, $020E, $ABF2;
-
- function GetThreadStateGivenTaskRef (threadTRef: ThreadTaskRef; threadToGet: ThreadID; var threadStat: ThreadState): OSErr;
- inline
- $303C, $060F, $ABF2;
-
- function SetThreadReadyGivenTaskRef (threadTRef: ThreadTaskRef; threadToSet: ThreadID): OSErr;
- inline
- $303C, $0410, $ABF2;
-
- implementation
-
- end.